﻿using System;
using System.IO;
using System.Collections.Generic;
using OfficeOpenXml;

namespace createSQL
{
    class Program
    {
        const int TABLE_LENGTH = 8;
        const int START_COL = 2;
        const int START_ROW = 3;
        const int TABLE_NAME_COL = 3;
        static void Main(string[] args)
        {
            DirectoryInfo di = new DirectoryInfo(@".\input\");
            FileInfo[] fis = di.GetFiles("*.xlsx");
            foreach (var file in fis)
            {
                var tableStartRow = START_ROW;
                using (var p = new ExcelPackage(file))
                {
                    var targetSheet = p.Workbook.Worksheets["_table"];
                    var parser = new MySQLParser();
                    while (!parser.isEnd(tableStartRow, targetSheet))
                    {
                        tableStartRow = parser.ReadTable(tableStartRow, ref targetSheet);
                    }
                    
                    p.SaveAs(new FileInfo($@".\output\{p.File.Name}"));
                }
            }
        }
    }
}
